package cn.lyq.card.data.model

import cn.lyq.card.utils.toMoney
import com.google.gson.annotations.SerializedName

class PosStatisticsInfo {

    @SerializedName("posNumber")
    var posNumber = 0

    @SerializedName("goods_id")
    var goodsId = 0

    @SerializedName("title")
    var title: String? = null

    @SerializedName("posActNumber")
    var posActNumber = 0

    @SerializedName("posNotActNumber")
    var posNotActNumber = 0

    var pieList = mutableListOf<PosPieInfo>()

    fun getPie(): MutableList<PosPieInfo> {
        if (pieList.size == 0) {
            pieList.addAll(PosPieInfo.create(this))
        }
        return pieList
    }

    fun getActPercent() =
        if (posNumber == 0) "0.00%" else "${(posActNumber.toDouble() * 100 / posNumber).toMoney()}%"

    fun getNotActPercent() =
        if (posNumber == 0) "0.00%" else "${(posNotActNumber.toDouble() * 100 / posNumber).toMoney()}%"
}